'''
Author: m0_64409496 2045527544@qq.com
Date: 2025-05-06 16:24:50
LastEditors: m0_64409496 2045527544@qq.com
LastEditTime: 2025-05-06 17:18:54
FilePath: \django-warehouse-system\employee\models.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
from django.contrib.auth.models import AbstractUser
from django.db import models

class Employee(AbstractUser):
    ROLE_CHOICES = (
        (1, '管理员'),
        (2, '普通员工'),
    )
    SEX_CHOICES = (
        ('男', '男'),
        ('女', '女'),
    )
    STATUS_CHOICES = (
        (0, '禁用'),
        (1, '启用'),
    )

    name = models.CharField('姓名', max_length=50)
    phone = models.CharField('手机号', max_length=11)
    sex = models.CharField('性别', max_length=1, choices=SEX_CHOICES)
    id_number = models.CharField('身份证号', max_length=18)
    role = models.IntegerField('角色', choices=ROLE_CHOICES, default=2)
    status = models.IntegerField('状态', choices=STATUS_CHOICES, default=1)
    create_time = models.DateTimeField('创建时间', auto_now_add=True)
    update_time = models.DateTimeField('更新时间', auto_now=True)
    groups = models.ManyToManyField(
        'auth.Group',
        related_name='employee_set',
        blank=True,
        help_text='The groups this user belongs to.',
        verbose_name='groups',
    )
    user_permissions = models.ManyToManyField(
        'auth.Permission',
        related_name='employee_set',
        blank=True,
        help_text='Specific permissions for this user.',
        verbose_name='user permissions',
    )

    class Meta:
        verbose_name = '员工'
        verbose_name_plural = verbose_name
        ordering = ['-create_time']

    def __str__(self):
        return self.name 